package com.core.image.core.box;

import com.core.image.core.ReceivePacket;

import java.io.File;
import java.io.FileOutputStream;

/**
 * describe:
 *
 * @author 库琦
 * @date 2020/01/29
 */
public class FileReceivePacket extends ReceivePacket<FileOutputStream,File> {
   private final File file;
    public FileReceivePacket(long len,File file) {
            super(len);
         this.file = file;

    }
    @Override
    public File buildEntity(FileOutputStream stream) {
        return file;
    }

    @Override
    public FileOutputStream createStream() {
        try {
            return new FileOutputStream(file);
        }catch (Exception e){
            e.printStackTrace();
        }
            return null;

    }

    @Override
    public byte type() {
        return TYPE_STREAM_FILE;
    }
}
